package o;

import android.app.Notification;
import android.app.Notification.Builder;
import android.app.PendingIntent;
import android.app.RemoteInput;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.RemoteViews;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationCompat.Action;
import androidx.core.app.NotificationCompat.a;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

@RestrictTo({d.ॱ})
public class fj implements fl {
    private RemoteViews ʻ;
    private int ʼ;
    private final List<Bundle> ˊ = new ArrayList();
    private final Builder ˋ;
    private RemoteViews ˎ;
    private final NotificationCompat.d ˏ;
    private RemoteViews ॱ;
    private final Bundle ॱॱ = new Bundle();

    public fj(NotificationCompat.d dVar) {
        boolean z;
        this.ˏ = dVar;
        if (VERSION.SDK_INT >= 26) {
            this.ˋ = new Builder(dVar.ˋ, dVar.ˋˋ);
        } else {
            this.ˋ = new Builder(dVar.ˋ);
        }
        Notification notification = dVar.ˎˏ;
        Builder lights = this.ˋ.setWhen(notification.when).setSmallIcon(notification.icon, notification.iconLevel).setContent(notification.contentView).setTicker(notification.tickerText, dVar.ᐝ).setVibrate(notification.vibrate).setLights(notification.ledARGB, notification.ledOnMS, notification.ledOffMS);
        if ((notification.flags & 2) != 0) {
            z = true;
        } else {
            z = false;
        }
        lights = lights.setOngoing(z);
        if ((notification.flags & 8) != 0) {
            z = true;
        } else {
            z = false;
        }
        lights = lights.setOnlyAlertOnce(z);
        if ((notification.flags & 16) != 0) {
            z = true;
        } else {
            z = false;
        }
        lights = lights.setAutoCancel(z).setDefaults(notification.defaults).setContentTitle(dVar.mContentTitle).setContentText(dVar.ˎ).setContentInfo(dVar.ʼ).setContentIntent(dVar.ˊ).setDeleteIntent(notification.deleteIntent);
        PendingIntent pendingIntent = dVar.ॱॱ;
        if ((notification.flags & DnsConfig.MAX_CACHE_ENTRIES) != 0) {
            z = true;
        } else {
            z = false;
        }
        lights.setFullScreenIntent(pendingIntent, z).setLargeIcon(dVar.mLargeIcon).setNumber(dVar.ʻ).setProgress(dVar.ॱᐝ, dVar.ॱˎ, dVar.ᐝॱ);
        if (VERSION.SDK_INT < 21) {
            this.ˋ.setSound(notification.sound, notification.audioStreamType);
        }
        if (VERSION.SDK_INT >= 16) {
            this.ˋ.setSubText(dVar.ˏॱ).setUsesChronometer(dVar.ͺ).setPriority(dVar.ʽ);
            Iterator it = dVar.ˏ.iterator();
            while (it.hasNext()) {
                ˋ((Action) it.next());
            }
            if (dVar.ˉ != null) {
                this.ॱॱ.putAll(dVar.ˉ);
            }
            if (VERSION.SDK_INT < 20) {
                if (dVar.ʾ) {
                    this.ॱॱ.putBoolean("android.support.localOnly", true);
                }
                if (dVar.ʻॱ != null) {
                    this.ॱॱ.putString("android.support.groupKey", dVar.ʻॱ);
                    if (dVar.ॱˋ) {
                        this.ॱॱ.putBoolean("android.support.isGroupSummary", true);
                    } else {
                        this.ॱॱ.putBoolean("android.support.useSideChannel", true);
                    }
                }
                if (dVar.ˈ != null) {
                    this.ॱॱ.putString("android.support.sortKey", dVar.ˈ);
                }
            }
            this.ॱ = dVar.ˋˊ;
            this.ˎ = dVar.ˋᐝ;
        }
        if (VERSION.SDK_INT >= 19) {
            this.ˋ.setShowWhen(dVar.ˋॱ);
            if (!(VERSION.SDK_INT >= 21 || dVar.ˏˎ == null || dVar.ˏˎ.isEmpty())) {
                this.ॱॱ.putStringArray("android.people", (String[]) dVar.ˏˎ.toArray(new String[dVar.ˏˎ.size()]));
            }
        }
        if (VERSION.SDK_INT >= 20) {
            this.ˋ.setLocalOnly(dVar.ʾ).setGroup(dVar.ʻॱ).setGroupSummary(dVar.ॱˋ).setSortKey(dVar.ˈ);
            this.ʼ = dVar.ˏˏ;
        }
        if (VERSION.SDK_INT >= 21) {
            this.ˋ.setCategory(dVar.ʿ).setColor(dVar.ˊᐝ).setVisibility(dVar.ˊˋ).setPublicVersion(dVar.ˊˊ).setSound(notification.sound, notification.audioAttributes);
            Iterator it2 = dVar.ˏˎ.iterator();
            while (it2.hasNext()) {
                this.ˋ.addPerson((String) it2.next());
            }
            this.ʻ = dVar.ˍ;
            if (dVar.ॱ.size() > 0) {
                Bundle bundle;
                Bundle bundle2 = dVar.ॱ().getBundle("android.car.EXTENSIONS");
                if (bundle2 == null) {
                    bundle = new Bundle();
                } else {
                    bundle = bundle2;
                }
                Bundle bundle3 = new Bundle();
                for (int i = 0; i < dVar.ॱ.size(); i++) {
                    bundle3.putBundle(Integer.toString(i), fn.ˏ((Action) dVar.ॱ.get(i)));
                }
                bundle.putBundle("invisible_actions", bundle3);
                dVar.ॱ().putBundle("android.car.EXTENSIONS", bundle);
                this.ॱॱ.putBundle("android.car.EXTENSIONS", bundle);
            }
        }
        if (VERSION.SDK_INT >= 24) {
            this.ˋ.setExtras(dVar.ˉ).setRemoteInputHistory(dVar.ॱˊ);
            if (dVar.ˋˊ != null) {
                this.ˋ.setCustomContentView(dVar.ˋˊ);
            }
            if (dVar.ˋᐝ != null) {
                this.ˋ.setCustomBigContentView(dVar.ˋᐝ);
            }
            if (dVar.ˍ != null) {
                this.ˋ.setCustomHeadsUpContentView(dVar.ˍ);
            }
        }
        if (VERSION.SDK_INT >= 26) {
            this.ˋ.setBadgeIconType(dVar.ˎˎ).setShortcutId(dVar.ˌ).setTimeoutAfter(dVar.ˑ).setGroupAlertBehavior(dVar.ˏˏ);
            if (dVar.ʽॱ) {
                this.ˋ.setColorized(dVar.ʼॱ);
            }
            if (!TextUtils.isEmpty(dVar.ˋˋ)) {
                this.ˋ.setSound(null).setDefaults(0).setLights(0, 0, 0).setVibrate(null);
            }
        }
    }

    public Builder ˊ() {
        return this.ˋ;
    }

    public Notification ॱ() {
        a aVar = this.ˏ.ˊॱ;
        if (aVar != null) {
            aVar.ॱ(this);
        }
        RemoteViews ˊ = aVar != null ? aVar.ˊ(this) : null;
        Notification ˋ = ˋ();
        if (ˊ != null) {
            ˋ.contentView = ˊ;
        } else if (this.ˏ.ˋˊ != null) {
            ˋ.contentView = this.ˏ.ˋˊ;
        }
        if (VERSION.SDK_INT >= 16 && aVar != null) {
            ˊ = aVar.ˋ(this);
            if (ˊ != null) {
                ˋ.bigContentView = ˊ;
            }
        }
        if (VERSION.SDK_INT >= 21 && aVar != null) {
            ˊ = this.ˏ.ˊॱ.ˏ((fl) this);
            if (ˊ != null) {
                ˋ.headsUpContentView = ˊ;
            }
        }
        if (VERSION.SDK_INT >= 16 && aVar != null) {
            Bundle ॱ = NotificationCompat.ॱ(ˋ);
            if (ॱ != null) {
                aVar.ˏ(ॱ);
            }
        }
        return ˋ;
    }

    private void ˋ(Action action) {
        if (VERSION.SDK_INT >= 20) {
            Bundle bundle;
            Notification.Action.Builder builder = new Notification.Action.Builder(action.ˏ(), action.ˊ(), action.ˎ());
            if (action.ॱॱ() != null) {
                for (RemoteInput addRemoteInput : androidx.core.app.RemoteInput.ˊ(action.ॱॱ())) {
                    builder.addRemoteInput(addRemoteInput);
                }
            }
            if (action.ˋ() != null) {
                bundle = new Bundle(action.ˋ());
            } else {
                bundle = new Bundle();
            }
            bundle.putBoolean("android.support.allowGeneratedReplies", action.ॱ());
            if (VERSION.SDK_INT >= 24) {
                builder.setAllowGeneratedReplies(action.ॱ());
            }
            bundle.putInt("android.support.action.semanticAction", action.ʻ());
            if (VERSION.SDK_INT >= 28) {
                builder.setSemanticAction(action.ʻ());
            }
            bundle.putBoolean("android.support.action.showsUserInterface", action.ʼ());
            builder.addExtras(bundle);
            this.ˋ.addAction(builder.build());
        } else if (VERSION.SDK_INT >= 16) {
            this.ˊ.add(fn.ˋ(this.ˋ, action));
        }
    }

    protected Notification ˋ() {
        if (VERSION.SDK_INT >= 26) {
            return this.ˋ.build();
        }
        Notification build;
        if (VERSION.SDK_INT >= 24) {
            build = this.ˋ.build();
            if (this.ʼ == 0) {
                return build;
            }
            if (!(build.getGroup() == null || (build.flags & WXMediaMessage.TITLE_LENGTH_LIMIT) == 0 || this.ʼ != 2)) {
                ॱ(build);
            }
            if (build.getGroup() == null || (build.flags & WXMediaMessage.TITLE_LENGTH_LIMIT) != 0 || this.ʼ != 1) {
                return build;
            }
            ॱ(build);
            return build;
        } else if (VERSION.SDK_INT >= 21) {
            this.ˋ.setExtras(this.ॱॱ);
            build = this.ˋ.build();
            if (this.ॱ != null) {
                build.contentView = this.ॱ;
            }
            if (this.ˎ != null) {
                build.bigContentView = this.ˎ;
            }
            if (this.ʻ != null) {
                build.headsUpContentView = this.ʻ;
            }
            if (this.ʼ == 0) {
                return build;
            }
            if (!(build.getGroup() == null || (build.flags & WXMediaMessage.TITLE_LENGTH_LIMIT) == 0 || this.ʼ != 2)) {
                ॱ(build);
            }
            if (build.getGroup() == null || (build.flags & WXMediaMessage.TITLE_LENGTH_LIMIT) != 0 || this.ʼ != 1) {
                return build;
            }
            ॱ(build);
            return build;
        } else if (VERSION.SDK_INT >= 20) {
            this.ˋ.setExtras(this.ॱॱ);
            build = this.ˋ.build();
            if (this.ॱ != null) {
                build.contentView = this.ॱ;
            }
            if (this.ˎ != null) {
                build.bigContentView = this.ˎ;
            }
            if (this.ʼ == 0) {
                return build;
            }
            if (!(build.getGroup() == null || (build.flags & WXMediaMessage.TITLE_LENGTH_LIMIT) == 0 || this.ʼ != 2)) {
                ॱ(build);
            }
            if (build.getGroup() == null || (build.flags & WXMediaMessage.TITLE_LENGTH_LIMIT) != 0 || this.ʼ != 1) {
                return build;
            }
            ॱ(build);
            return build;
        } else if (VERSION.SDK_INT >= 19) {
            r0 = fn.ॱ(this.ˊ);
            if (r0 != null) {
                this.ॱॱ.putSparseParcelableArray("android.support.actionExtras", r0);
            }
            this.ˋ.setExtras(this.ॱॱ);
            build = this.ˋ.build();
            if (this.ॱ != null) {
                build.contentView = this.ॱ;
            }
            if (this.ˎ == null) {
                return build;
            }
            build.bigContentView = this.ˎ;
            return build;
        } else if (VERSION.SDK_INT < 16) {
            return this.ˋ.getNotification();
        } else {
            Notification build2 = this.ˋ.build();
            Bundle ॱ = NotificationCompat.ॱ(build2);
            Bundle bundle = new Bundle(this.ॱॱ);
            for (String str : this.ॱॱ.keySet()) {
                if (ॱ.containsKey(str)) {
                    bundle.remove(str);
                }
            }
            ॱ.putAll(bundle);
            r0 = fn.ॱ(this.ˊ);
            if (r0 != null) {
                NotificationCompat.ॱ(build2).putSparseParcelableArray("android.support.actionExtras", r0);
            }
            if (this.ॱ != null) {
                build2.contentView = this.ॱ;
            }
            if (this.ˎ != null) {
                build2.bigContentView = this.ˎ;
            }
            return build2;
        }
    }

    private void ॱ(Notification notification) {
        notification.sound = null;
        notification.vibrate = null;
        notification.defaults &= -2;
        notification.defaults &= -3;
    }
}
